from sklearn.model_selection import train_test_split
from sklearn import tree
from sklearn.datasets import load_wine
import pandas as pd
wine = load_wine()
X = wine.data
Y = wine.target
features_name = wine.feature_names
print(features_name)
print(pd.concat([pd.DataFrame(X), pd.DataFrame(Y)], axis=1))
x_train, x_test, y_train, y_test = train_test_split(
        X, Y, test_size=0.2, random_state=0)
clf = tree.DecisionTreeClassifier(criterion="entropy")
clf.fit(x_train, y_train)
score = clf.score(x_test, y_test)
y_predict = clf.predict(x_test)
print('准确率为:', score)
print(pd.concat([pd.DataFrame(x_test), pd.DataFrame(y_test), pd.DataFrame(y_predict)], axis=1))
